#include "rightlightbutton.h"
#include "ui_rightlightbutton.h"

rightLightButton::rightLightButton(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::rightLightButton)
{
    ui->setupUi(this);
    initForm();
}

rightLightButton::~rightLightButton()
{
    delete ui;
}
void rightLightButton::initForm()
{
    type = 0;

    timer = new QTimer(this);
    timer->setInterval(100);
    connect(timer, SIGNAL(timeout()), this, SLOT(updateValue()));
//    timer->start();
//    updateValue();
}

void rightLightButton::updateValue()
{
    btnsLight<<ui->widget1<<ui->widget2<<ui->widget3<<ui->widget4<<ui->widget5<<ui->widget6<<ui->widget7<<ui->widget8;
    int count = btnsLight.count();
    for(int i = 0 ; i < count; i++)
    {
        btnsLight.at(i)->setLightGreen();
    }
    btnsLight.at(type)->setLightRed();
    btnsLight.at(type+1)->setLightRed();
    type++;
    if(type == 8)
        type = 0;

}
void rightLightButton::setStartOrStop(bool flag)
{
    if(flag)
        timer->start();
    else
        timer->stop();
}
